package com.hourupdate.network.bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.hourupdate.network.connection.ConnectionJDBC;

public class ChannelDetailNews {
	static final Logger logger = Logger.getLogger(ChannelDetailNews.class);
	private String cn_id = null;
	private String cdn_id = null;
	private String cdn_title = null;
	private String cdn_desc = null;
	private String cdn_publish_date = null;
	private String cdn_link = null;
	private String cdn_image = null;
	private String cdn_create_date = null;
	public String getCn_id() {
		return cn_id;
	}
	public void setCn_id(String cn_id) {
		this.cn_id = cn_id;
	}
	public String getCdn_id() {
		return cdn_id;
	}
	public void setCdn_id(String cdn_id) {
		this.cdn_id = cdn_id;
	}
	public String getCdn_title() {
		return cdn_title;
	}
	public void setCdn_title(String cdn_title) {
		this.cdn_title = cdn_title;
	}
	public String getCdn_desc() {
		return cdn_desc;
	}
	public void setCdn_desc(String cdn_desc) {
		this.cdn_desc = cdn_desc;
	}
	public String getCdn_publish_date() {
		return cdn_publish_date;
	}
	public void setCdn_publish_date(String cdn_publish_date) {
		this.cdn_publish_date = cdn_publish_date;
	}
	public String getCdn_link() {
		return cdn_link;
	}
	public void setCdn_link(String cdn_link) {
		this.cdn_link = cdn_link;
	}
	public String getCdn_image() {
		return cdn_image;
	}
	public void setCdn_image(String cdn_image) {
		this.cdn_image = cdn_image;
	}
	public String getCdn_create_date() {
		return cdn_create_date;
	}
	public void setCdn_create_date(String cdn_create_date) {
		this.cdn_create_date = cdn_create_date;
	}
	public boolean insertPreparedStatement(Connection conn){
		String sql = "INSERT INTO "+ConnectionJDBC.schema+"."+ConnectionJDBC.schemaCHANNEL_DETAIL_NEWS+
					"(" +
					"CN_ID,"+
					"CDN_ID,"+
					"CDN_TITLE,"+
					"CDN_DESC,"+
					"CDN_PUBLISH_DATE,"+
					"CDN_LINK,"+
					"CDN_IMAGE,"+
					"CDN_CREATE_DATE" +
					")"+
					"VALUES"+
					"("+
					"?,"+
					"?,"+
					"?,"+
					"?,"+
					"?,"+
					"?,"+
					"?,"+
					"?"+
					")";
		boolean success = false;
		try {
			PreparedStatement ps = conn.prepareStatement(sql);
			ExecuteSQLBean eb = new ExecuteSQLBean();
			ps.setString(1, this.getCn_id());
			ps.setString(2, this.getCdn_id());
			ps.setString(3, this.getCdn_title());
			ps.setString(4, this.getCdn_desc());
			ps.setString(5, this.getCdn_publish_date());
			ps.setString(6, this.getCdn_link());
			ps.setString(7, this.getCdn_image());
			ps.setString(8, this.getCdn_create_date());
			success = eb.executeStatement(ps);
			ps.close();
		} catch (SQLException e) {
			logger.error(e.getMessage());
		}
		return success;
	}
	
}
